<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.google.appengine.api.users.User"%>
<%@ page import="com.google.appengine.api.users.UserService"%>
<%@ page import="com.google.appengine.api.users.UserServiceFactory"%>
<%@ page import="javax.jdo.PersistenceManager"%>
<%@ page import="howl.model.Model"%>
<%@ page import="java.util.List"%>
<%@ page import="howl.types.HowlUser"%>
<%@ page import="howl.Twitter.EnableTwitter"%>
<%@ page import="javax.jdo.Query"%>
<%
try {
	UserService userService = UserServiceFactory.getUserService();
	User user = userService.getCurrentUser();
	List<HowlUser> results = null;
	HowlUser h = null;
	if (user == null) {
		response.sendRedirect("/Welcome.jsp");
	} else {
		

		h = Model.getHowlUserfromUser(user);
		Model m = new Model(h);
		if (h == null) {
			response.sendRedirect("/Signup.jsp");
		} else {
			
		h = m.getHowlUser();
			
			if (h.isTwitter() && !h.isTwitterisConfigured()) {
				response
						.sendRedirect(EnableTwitter.enableTwitter(user));
				
			}
			
			

			if (((h.isTwitter() && h.isTwitterisConfigured()) || !h.isTwitter())
					&& ((h.isLayar() && h.isLayarisConfigured()) || !h.isLayar())
					&& ((h.isPachube() && h.isPachubeisConfigured()) || !h.isPachube())
					&& ((h.isYourFlowingData() && h.isYourFlowingDataisConfigured()) || !h.isYourFlowingData())) {
				h.setFirstTimeUser(false);
				m.getPm().close();
				response.sendRedirect("/Auth/index.jsp");
			}
			

		}

	}
} catch (Exception e ){
	%>
	<%=e.toString()%>
	<%
}
%>
